from django.db import models

# Create your models here.
class Users(models.Model):
    username=models.CharField(max_length=16,verbose_name='用户名')
    password=models.CharField(max_length=128,verbose_name='密码')
    mobile=models.CharField(max_length=11,verbose_name='手机号')
    class Meta:
        db_table='users'
        verbose_name='用户名'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.username

class NameV(models.Model):
    username = models.CharField(max_length=16, verbose_name='昵称')
    title = models.CharField(max_length=128, verbose_name='头像')
    user = models.ForeignKey(Users, on_delete=models.CASCADE, verbose_name='所属用户')
    class Meta:
        db_table='names'
        verbose_name='昵称表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.username


class People(models.Model):
    name=models.CharField(max_length=16,verbose_name='昵称')
    sex = models.CharField(max_length=16, verbose_name='性别')
    title=models.CharField(max_length=128,verbose_name='头像')
    user=models.ForeignKey(Users,on_delete=models.CASCADE,verbose_name='所属用户')
    class Meta:
        db_table='people'
        verbose_name='个人信息表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.name

class Address(models.Model):
    name=models.CharField(max_length=16,verbose_name='姓名')
    mobile = models.CharField(max_length=11, verbose_name='手机号')
    addr=models.CharField(max_length=128,verbose_name='地址')
    people=models.ForeignKey(People,on_delete=models.CASCADE,verbose_name='所属个人信息')
    class Meta:
        db_table='address'
        verbose_name='地址表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.name

class Cate(models.Model):
    kind=models.CharField(max_length=16,verbose_name='种类')
    class Meta:
        db_table='cate'
        verbose_name='种类表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.kind

class Shopp(models.Model):
    name = models.CharField(max_length=16, verbose_name='商品名')
    price = models.IntegerField(default=0, verbose_name='商品价格')
    desc = models.CharField(max_length=16, verbose_name='商品描述')
    kind=models.ForeignKey(Cate,on_delete=models.CASCADE,verbose_name='种类描述')
    class Meta:
        db_table='shopp'
        verbose_name='商品表'
        verbose_name_plural=verbose_name
    def __str__(self):
        return self.name


